package crp.services.api.graphql.models;

import crp.core.security.domain.models.RoleEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;
import java.util.List;

@Type("Role")
@Builder
@Getter
@AllArgsConstructor
public class RolePayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String name;
    @NotNull
    private final List<@NotNull String> permissions;

    public static RolePayload of(RoleEntity entity) {
        return RolePayload.builder()
                .id(entity.getId())
                .name(entity.getName())
                .permissions(entity.getPermissions())
                .build();
    }
}
